package thread;

import static java.lang.Thread.sleep;
//使用lambda 表达式
public class ThreadDemo6 {
    public static void main(String[] args) {
        Thread t = new Thread(()->{
            while (true) {
                System.out.println("hello thread");;
                try {
                    sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();
        t.setDaemon(true); //设置为后台进程
        System.out.println(t.getId());
        System.out.println(t.getName());
    }
}
